﻿using System;

using NUnit.Framework;

using octalforty.Syndication.Core;
using octalforty.Syndication.Core.Rss;

namespace octalforty.Syndication.UnitTests.Core.Rss
{
    /// <summary>
    /// <see cref="Rss208Syndicator"/> unit tests.
    /// </summary>
    [TestFixture()]
    public class Rss208SyndicatorTestFixture
    {
        [Test()]
        [ExpectedException(typeof(ArgumentNullException))]
        public void SyndicateDoesNotAllowNullValues()
        {
            ISyndicator syndicator = new Rss208Syndicator();
            syndicator.Syndicate(null);
        }

        [Test()]
        [ExpectedException(typeof(SyndicationException))]
        public void SyndicateDoesNotAllowNullSyndicationFeedTitle()
        {
            ISyndicationFeed syndicationFeed = new SyndicationFeed();
            
            syndicationFeed.Description = "Description";
            syndicationFeed.Link = "Link";
            syndicationFeed.Title = null;

            ISyndicator syndicator = new Rss208Syndicator();
            syndicator.Syndicate(syndicationFeed);
        }

        [Test()]
        [ExpectedException(typeof(SyndicationException))]
        public void SyndicateDoesNotAllowEmptySyndicationFeedTitle()
        {
            ISyndicationFeed syndicationFeed = new SyndicationFeed();
            
            syndicationFeed.Description = "Description";
            syndicationFeed.Link = "Link";
            
            ISyndicator syndicator = new Rss208Syndicator();
            syndicator.Syndicate(syndicationFeed);
        }

        [Test()]
        [ExpectedException(typeof(SyndicationException))]
        public void SyndicateDoesNotAllowNullSyndicationFeedDescription()
        {
            ISyndicationFeed syndicationFeed = new SyndicationFeed();

            syndicationFeed.Title = "Title";
            syndicationFeed.Link = "Link";
            syndicationFeed.Description = null;

            ISyndicator syndicator = new Rss208Syndicator();
            syndicator.Syndicate(syndicationFeed);
        }

        [Test()]
        [ExpectedException(typeof(SyndicationException))]
        public void SyndicateDoesNotAllowEmptySyndicationFeedDescription()
        {
            ISyndicationFeed syndicationFeed = new SyndicationFeed();

            syndicationFeed.Title = "Title";
            syndicationFeed.Link = "Link";

            ISyndicator syndicator = new Rss208Syndicator();
            syndicator.Syndicate(syndicationFeed);
        }

        [Test()]
        [ExpectedException(typeof(SyndicationException))]
        public void SyndicateDoesNotAllowNullSyndicationFeedLink()
        {
            ISyndicationFeed syndicationFeed = new SyndicationFeed();
            
            syndicationFeed.Title = "Title";
            syndicationFeed.Description = "Description";
            syndicationFeed.Link = null;

            ISyndicator syndicator = new Rss208Syndicator();
            syndicator.Syndicate(syndicationFeed);
        }

        [Test()]
        [ExpectedException(typeof(SyndicationException))]
        public void SyndicateDoesNotAllowEmptySyndicationFeedLink()
        {
            ISyndicationFeed syndicationFeed = new SyndicationFeed();

            syndicationFeed.Title = "Title";
            syndicationFeed.Description = "Description";

            ISyndicator syndicator = new Rss208Syndicator();
            syndicator.Syndicate(syndicationFeed);
        }
    }
}
